package com.abc.generator;

import static org.junit.Assert.*;

import java.util.Map;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.abc.model.PersonYearEffort;
import com.abc.model.Project;
import com.abc.model.ProjectYear;
import com.abc.model.ReportRepository;
import com.abc.generator.TestGral;

public class FirstTestGral {
	
	private Project projData;
	
	private ReportRepository repository;
	
	@Before
	public void setUp() throws Exception {
		projData = null;
		repository = new ReportRepository();
	}

	@After
	public void tearDown() throws Exception {
	}
	
	

	@Test
	public void testplot() {
				//Given
				String theYear = "2010";
				String[] yearList = {"2014", "2009", theYear};
				String expectedProjectName = "project 1";
				initRepo(expectedProjectName, yearList, "Developer");
				String theYear1 = "2010";
				String[] yearList1 = {"2014", "2009", theYear1};
				String expectedProjectName1 = "project 2";
				initRepo(expectedProjectName1, yearList1, "Developer1");
				


				
				//Than
				//TestGral wynik = new TestGral.repository.getAllEffortsForEmployee("Developer")();
				assertEquals(2, repository.getAllEffortsForEmployee("Developer").length);
				//assertEquals(1, developersSize);
//				assertEquals(190., developers.get(0).getEffort(theYear, 4), .001);
//				
	}
	
	private void initRepo(String expectedName, String[] projYears, String dev) {
		projData = initProj(expectedName, projYears, dev);
		repository.addProject(projData);
	}

	private Project initProj(String projName, String[] projYears, String devName) {
		
		String devOne = "devOne";
		
		Project one = new Project(projName);
		
		for(int i = 0; i < projYears.length; i++) {
			
			PersonYearEffort devYear = new PersonYearEffort(devOne, projYears[i]);
			devYear.addEffort(2, 50.2);
			devYear.addEffort(3, 60);
			devYear.setEffort(4, 190);
			
			ProjectYear pYear = new ProjectYear();
			pYear.addPersonEfforts(devYear);
			
			one.addProjectYear(pYear);
			
		}
		return one;
	
	}

}
